import { createSlice } from '@reduxjs/toolkit'
const userStore = createSlice({
  name: 'user',
  //初始化状态
  initialState: {
    token: ''
  },
  //修改状态的方法,同步方法，支持直接修改
  reducers: {
    setToken: (state, action) => {
      state.token = action.payload
    }
  }
})
//解构出来actionCreater函数

const { setToken } = userStore.actions
const reducer = userStore.reducer
export { setToken }
//导出
export default reducer
